<?php

/**
 * Albireo Kernel
 *
 * @copyright  Copyright (c) 2010 Albireo Solutions
 * @package    Kernel
 */

namespace WebtopModule\ApplicationModule;

use WebtopModule\BasePresenter;
use Albireo\Application\ApplicationExecutor;

/**
 * Rest presenter.
 * Does not have to check parameters
 * rpcManagement have to take care of it
 *
 * Just because of performance
 *
 * @author     petr
 * @package    Api
 */
//TODO: Do we want to give permissions to access API?
class ApplicationPresenter extends BasePresenter {

    /**
     * @var Albireo\Application\ApplicationExecutor
     */
    private $appExecutor;

    /**
     * startup is always called
     */
    public function startup() {
        parent::startup();
        $this->appExecutor = new ApplicationExecutor($this->getUser());
    }

    public function actionDefault() {
        $this->changeAction("execute");
    }

    public function actionExecute($name, $args, $flags, $settings) {
        $this->template->data = $this->appExecutor->execute($name, $args, $flags, $settings);
        $this->view = "albireo";
    }

    //public function update
}